<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>门店切换时间</title>
<%@include file="../include/include.jsp"%>
<link rel="stylesheet" type="text/css" href="${csspath }/public.css" />
<script type="text/javascript" src="${layerPath}/jquery/jquery-1.8.3.js"></script>
<link rel="stylesheet" type="text/css"
	href="${bootstrapPath}/css/bootstrap.css" />
<script type="text/javascript" src="${bootstrapPath}/js/bootstrap.js"></script>
<link rel="stylesheet" type="text/css" href="${csspath }/datepicker.css"/>
<script type="text/javascript" src="${jspath }/ui.datepicker_zh-CN.js"></script>
<script type="text/javascript" src="${jspath }/jquery.ui.min.js"></script>
<script type="text/javascript"
	src="${bootstrapPath}/js/bootstrap3-validation.js"></script>
<script type="text/javascript" src="${layerPath}/layer.js"></script>
<script type="text/javascript" src="${layerPath}/extend/layer.ext.js"></script>
	
<script type="text/javascript">
function search() {
	dealerChange.action = "${webcontext}/crmdp/dealer/masterdata/toDealerChange";
	document.getElementById("dealerChange").submit();
}

function saveChange(o,p){
	if($.trim($("#"+ p).val()) == ""){
		jAlert("切换日期不能为空！","提示信息");
		return;
	}
	$.ajax({
		url : "${webcontext}/crmdp/dealer/masterdata/updateDealerChange?dealerNum="+ encodeURI(encodeURI(o)) + "&changeDate="+ encodeURI(encodeURI($("#"+ p).val())),
		type : 'post',
		success : function(data) {
			if(data == true){
				jAlert("修改成功","提示信息");
			}else{
				jAlert("修改失败","提示信息");
			}
		}
	});
}

function addChange(){
	var url = "${webcontext}/crmdp/dealer/masterdata/toAddDealerChange";
	//iframe层
	layer.open({
	    type: 2,
	    title: '添加记录',
	    shadeClose: false,
	    closeBtn: false,
	    shade: 0.1, 
	    offset : ['3%' , '25%'],
	    area: ['400px', '350px'],
	    content: url,//iframe的url
	    end: function(){ 
	    	//关闭弹出层后回调方法
	    	window.location.href="${webcontext}/crmdp/dealer/masterdata/toDealerChange";
	    }
	});
}

$(function(){
	$("#queryInfo_btn").click(function(){
		dealerChange.action="${webcontext}/crmdp/dealer/masterdata/toDealerChange";
		document.getElementById("dealerChange").submit();
	});
})
</script>
</head>
<style>
.form-control1 {
	width: 100%;
	height: 34px;
	padding: 6px 12px;
	font-size: 14px;
	line-height: 1.42857;
	color: #555;
	background-color: #FFF;
	background-image: none;
	border: 1px solid #CCC;
	border-radius: 0px;
	box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.075) inset;
	transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s
		ease-in-out 0s;
}
</style>
<body>
<div id="content">
		<div id="wrap">
	<div class="main" style="margin-top: 10px;">
		<form:form class="form-horizontal" id="dealerChange" method="post"
			action="" role="form"
			enctype="multipart/form-data">
			<div class="form-inline" style="text-align: center; margin-top: 10px;margin-left: -50px;">
				<div class="form-group">
					<label class="col-sm-4 control-label">门店号</label>
					<div class="col-sm-3">
						<input class="form-control input-sm" id="dealerNum" name="dealerNum" type="text" value="${dealerChangeDto.dealerNum}" />
					</div>
				</div>
				<div class="form-group">	
					<label class="col-sm-5 control-label" for="startDate">切换日期</label>
					<div class="col-sm-2">
						<input name="changeStartDate" class="form-control input-sm validate[length[0,100]] date" id="startDate" type="text"
							 value="${dealerChangeDto.changeStartDate}" />
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-5 control-label text-center" for="endDate">至</label>
					<div class="col-sm-2">
						<input  name="changeEndDate" class="form-control input-sm validate[length[0,100]] date" id="endDate" type="text" 
						 value="${dealerChangeDto.changeEndDate}" />
					</div>
				</div>
			</div>
			<div style="text-align: center; margin-top: 20px;">
				<button id="queryInfo_btn" type="button"class="btn btn-success btn-sm" style="width: 100px;">
					<i class="glyphicon glyphicon-search icon" style="color:#FFFFFF"></i>&nbsp;查询
				</button>
				<button type="button" class="btn btn-success btn-sm" onclick="addChange();">添加记录</button>
			</div>
			<div style="width: 99%; height: auto; margin-top: 10px;">
				<table id="data_tab" class="table table-hover">
					<thead>
						<tr>
							<th width="20%" height="20">门店号</th>
							<th width="50%" height="20" >店名</th>
							<th width="30%" height="20" >切换日期</th>
						</tr>
					</thead>
					<tbody>
						<core:forEach items="${dealerChangeDtoList}" var="list">
							<tr>
								<td class="text-left">${list.dealerNum}</td>
								<td class="text-left">${list.dealerName}</td>
								<td class="text-left">
									<input type="text" id="changeDate${list.dealerNum}" value="${list.changeDate}" class="form-control1  date" style="width: 130px;"/>
									<button type="button" class="btn btn-success btn-xs" onclick="saveChange('${list.dealerNum}','changeDate${list.dealerNum}');">保存修改</button>
								</td>
							</tr>
						</core:forEach>
					</tbody>
				</table>
				<div class="page_div">
					<%@include file="../common/page.jsp"%>
				</div>
			</div>
		</form:form>
	</div>
	</div>
	</div>
</body>
</html>